package com.tmeone.erpone.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tmeone.erpone.entity.JsonResult;
import com.tmeone.erpone.entity.TIomWarehouse;
import com.tmeone.erpone.service.ITIomWarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author tmeone
 * @since 2021-04-20
 */
@RestController
public class TIomWarehouseController {

    @Autowired
    private ITIomWarehouseService iomWarehouseService;

    //分页查询
    @GetMapping("/checks")
    public JsonResult getPageCheck(@RequestParam(value = "current",required = false,defaultValue = "1") Integer current,
                                   @RequestParam(value ="pageSize",required = false,defaultValue = "5") Integer pageSize){
        Page<TIomWarehouse> page = new Page<>(current, pageSize);
        IPage<TIomWarehouse> list = iomWarehouseService.pageCheck(page);
        return new JsonResult(1,list);
    }
    //查询单条数据
    @GetMapping("/lookDetails/{id}")
    public JsonResult getDetailsById(@PathVariable String id){
        List<TIomWarehouse> detail = iomWarehouseService.selectById(id);
        return new JsonResult(1,detail);
    }

    //根据条件查询单条
    @GetMapping("/checks/{ioNo}/{WName}/{pname}")
    public JsonResult getOne(@PathVariable String ioNo,@PathVariable String WName,@PathVariable String pname){
        List<TIomWarehouse> one = iomWarehouseService.getOne(ioNo, WName, pname);
        return new JsonResult(1,one);
    }
}
